class Person:
    def __init__(self, name, age):
        self.name = name
        self.age = age

    def __eq__(self, op):
        return self.name == op.name and self.age == op.age


p1 = Person('topson', 18)
p2 = Person('topson', 18)
# 判断两个对象是否是同一个对象，是看它们地址是否一样
print('&p1 = {}'.format(p1))
print('&p2 = {}'.format(p2))
# is 身份运算符(比较地址)
# ==   调用__eq__方法，获取比较结果
print(p1 is p2)
print(p1 == p2)  # ==>  p1.__eq__(p2)
nums1 = [1, 2]
nums2 = [1, 2]
print(nums1 is nums2)  # False
print(nums1 == nums2)  # True
